//特殊字符正则表达式 
var txt = new RegExp("[,\\',\\'']");
var templateSrc = "http://www.spider.com.cn";
/**邀约点击举报**/
function setcustomerid(source,cid){
	if(source == 'publish'){
		$("#sendlink").attr("onclick","savereport('publish');");
	}else{
		$("#sendlink").attr("onclick","savereport('apply');");
	}
	$("#reportid").val(cid);
	$("#jubaodiaolog").show();
	var jutop=$(document).scrollTop()+100;
	$("#jubaodianlog").show().css("top",jutop);
}
/**举报内容选择**/
function datingreport(ele){
	$(ele).toggleClass("slct");
}

/**提交举报内容**/
function savereport(source){
	var reportall = "";
	$("#jubao .slct").each(function(){
		reportall += $(this).attr("id") + ",";
	});
	if(reportall == ''){
		alert("请至少选择一项举报内容!");
		return;
	}
	var reportedid = "";
	var reportedname = "";
	var reportedalise = "";
	if('publish' == source){
		reportedid = $("#reportid").val();
		reportedname = $("#applyname" + reportedid).val();
		reportedalise = $("#applyalias" + reportedid).val();
	}else{
		reportedid = $("#reportid").val();
		reportedname = $("#publishusername" + reportedid).val();
		reportedalise = $("#publishalise" + reportedid).val();
	}
	var as = {
		"usertype":"second002",
		"reportall":reportall,
		"reporteduserid":reportedid,
		"reportedname":reportedname,
		"reportedalise":reportedalise
	};
	$.post("newuserjquery.action", as, function(data){
       	var items = data.getElementsByTagName("item");
     	var result = items[0].childNodes[0].nodeValue;
     	if(result == 'error'){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == 'false'){
	   		alert("更新失败,请稍后再试！");
	   		return ;
     	}else{
     		$("#jubaodiaolog").hide();
     		$("#shutdia").show();
     		$("#jubao .slct").each(function(){
				$(this).removeClass("slct");
			});
     	}
   	});
}

/**显示更多**/
function showhide(liid){
	$("#showflag").hide();
	$(".hideli" + liid).show();
	$("#hideflag").show();
}
/**收起更多**/
function hideshow(liid){
	$("#hideflag").hide();
	if(liid != ''){
		$(".hideli" + liid).hide();
	}
	$("#showflag").show();
}

/**关闭窗口**/
function closedia(eleid){
	$("#" + eleid).hide();
	$("#jubao .slct").each(function(){
		$(this).removeClass("slct");
	});
}

/************************************************商品订单操作***********************************/

/**取消订单弹出框**/
function canclethis(oid){
	$("#cancleoid").val(oid);
	$("#orderid").val(oid);
	$("#cnclRs").show();
}
/**取消订单**/
function realcancle(source){
	var cancelreason = $("input[name='reason']:checked").val();
	$("#cancelreason").val(cancelreason);
	if('all' == source){
		document.spiderorders.action = "/cancelorder.html";
		document.spiderorders.submit();
	}else{
		document.spiderorderdetail.action = "/cancelorder.html";
		document.spiderorderdetail.submit();
	}
}

/**打印订单**/
function printexcel(source,oid){
	if(source == 'all'){
		$("#orderid").val(oid);
		document.spiderorders.target="_blank";
    	document.spiderorders.action = "excelprint.html";
		document.spiderorders.submit();
	}else{
		document.spiderorderdetail.target="_blank";
    	document.spiderorderdetail.action = "excelprint.html";
		document.spiderorderdetail.submit();
	}
}

/**再次购买**/
function mulordercart(source,productids){
	if(source == 'detail'){
		productids = $("#allproductids").val();
	}
    var customerid = $("#customerid").val();
	var datainfo = {
			customerId: customerid,
			allproductinfo: productids
		};
	   $.ajax({ 
		url: spidercart+"/cart/batchadd",
		type: 'POST',
		contentType: 'application/json',
		dataType:"json",                 
        data:JSON.stringify(datainfo), 
		success: function(data){
			var result = data.respbase.returncode;
			if(result=="10000"){
					document.spiderorders.target = "_self";
					document.spiderorders.action = "/spiderCart_cartList.html";
					document.spiderorders.submit();
			}else{
				alert(data.respbase.returndesc);
       			return false;
			}	
		},
		error: function(data){
			alert("系统繁忙1");
   			return false;

		}
	});
}

/**订单详细页面去付款**/
function orderdetailOn(source,oid){
	if(source == 'all'){
		$("#orderid").val(oid);
		document.spiderorders.target="_blank";
		document.spiderorders.action = "orderconfirm.html";
		document.spiderorders.submit();
	}else{
		document.spiderorderdetail.action = "orderconfirm.html";
		document.spiderorderdetail.submit();
	}
}

/**********************************************电影票订单操作*******************************/
/**电影票取消订单**/
function canclefilmorder(fid){
	$("#canclefilmid").val(fid);
	$("#cnclRs").show();
	$(".mask").show();
}

function filmrealcancle(){
	var fid = $("#canclefilmid").val();
	var url_remote ="newuserjquery.action?usertype=second007&type=cancleorder&filmid=" + fid;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("#cnclRs").hide();
			$('.mask').hide();
			window.location.href = "accountfilmorders.html?status=detail&id=" + fid;
		}else{
			alert("系统繁忙，请稍后再试！");
		}
	});
}

/**申请理赔**/
function applylipei(fid){
	var url_remote ="newuserjquery.action?usertype=second007&type=applylipei&filmid=" + fid;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("lipei" + fid).hide();
			$("orderstatus" + fid).removeClass().addClass("odstate red1");
			$("orderstatus" + fid).html("理赔中");
			alert("申请成功！");
		}else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}else{
			alert(result);
		}
	});
}
/**发送取票短信**/
function sendmsgbefore(fid){
	$("#canclefilmid").val(fid);
	$("#sendmsg").show();
	$('.mask').show();
}

function sendmsgrea(){
	var fid = $("#canclefilmid").val();
	var url_remote ="newuserjquery.action?usertype=second007&type=sendmag&filmid=" + fid;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("#sendmsg").hide();
			$('.mask').hide();
			alert("发送成功！");
		}else if(result == "more"){
			$("#sendmsg").hide();
			$("#sendmsgmore").show();
			return;
		}else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}else{
			alert(result);
		}
	});
}

/**打印取票码**/
function printmsg(fid){
	var printcontent = $("#printcontent" + fid).val();
	$("#printcontent").html(printcontent.replace(/AAAA/g,"<").replace(/BBBB/g,">"));
	$("#printbutton").removeAttr("onclick");
	var linkcontent = $("#linkcontent" + fid).val();
	var clickcontent = "openWin('http://film.spider.com.cn/film_v4/printorder.jsp?" + linkcontent + "',480,300)";
	$("#printbutton").attr("onclick",clickcontent);
	$("#geticket").show();
}

function openWin(url,width,height){
	var phxWin = window.open(url,'蜘蛛网电影票订单信息','width='+width+',height='+height+'');
	phxWin.moveTo((screen.width-width)/2,(screen.height-height)/2);
}

/**发表评论**/
function commentdialog(fid){
	$("#filmid").val(fid);
	$("#showfilmname").html($("#uncommentname" + fid).val());
	$("#discussMsg").show();
}

function textareaMaxProc(){
	if($("#productcomment").val().length > 300){
		$("#productcomment").val($("#productcomment").val().substring(0,300));
		return false;
	}
	$("#zhishu").html($("#productcomment").val().length + "/300");
}

function publishcomment(source,level){
	var content = $("#productcomment").val();
	var parten = /^\s*$/;
	if(content == '' || parten.test(content)){
		alert("请输入评论内容!");
		$("#productcomment").focus();
		return;
	}else{
		if(txt.test(content)){
			alert("您输入了“'”特殊字符!");
			return;
		}
	}
	var filmid = $("#filmid").val();
	var url_remote ="newuserjquery.action?usertype=second007&type=publishcomment&filmid=" + filmid + "&content=" + content + "&level=" + level;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			if(source == 'comment'){
				$('#discussMsg').hide();
				alert("评论成功");
				window.location.href = templateSrc + "/myfilmcomment.html";
			}else{
				$('#discussMsg').hide();
				alert("评论成功");
			}
		}else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}else{
			alert(result);
		}
	});
}

/**********************************************电影票操作结束*******************************/

function shownext(type,pageno){
	var hiddenvalue = $("#hidden" + type).val();
	if(hiddenvalue == ''){
		$("#hidden" + type).val('1');
		turnpage(type,pageno);
	}
}

/**我的收藏页面翻页**/
function turnpage(type,pageno){
	if(type == "all"){
		type = "";
	}
	var url_remote ="newuserjquery.action?usertype=second005&pageno=" + pageno + "&type=" + type;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("#content" + type).html(items[1].childNodes[0].nodeValue);
			$("#page" + type).html(items[2].childNodes[0].nodeValue);
		}
	});
}

function checkAll(elename){
	$("[name='" + elename + "']").attr("checked",'true');	//全选
}

function clearAll(elename){
	$("[name='" + elename + "']").removeAttr("checked");	//取消全选
}

/**批量删除**/
function muldeletefavorte(elename){
    var id = "";
   	$("input[name='" + elename + "']:checked").each(function(){
   		id += $(this).val() + ",";
 	});
 	if(id == ""){
 		alert("请至少选择一项删除");
 		return false;
 	}
 	if("favourall" == elename){
 		elename = "all";
 	}else if("favourzz" == elename){
 		elename = "zz";
 	}else if("favourbz" == elename){
 		elename = "bz";
 	}else if("favourlp" == elename){
 		elename = "lp";
 	}else if("favourpq" == elename){
 		elename = "pq";
 	}
 	var url_remote ="newuserjquery.action?usertype=second006&id=" + id + "&type="+ elename;
    url_remote = encodeURI(url_remote);
 	$.post(url_remote, null, function(data){
    	var items = data.getElementsByTagName("item");   
   		var result = items[0].childNodes[0].nodeValue;
   		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
   		}else if(result != "success"){
 			alert("系统繁忙，请稍后再试！");
 			return false;
 		}else{
			window.location.href = templateSrc + "/accountfavorite.html";
		}
	});
}

/**加入购物车**/
function ordercart(productid, dymode){
	var url_remote ="productmodify.action?productType=first001&productid=" + productid+"&dymode="+dymode;
    url_remote = encodeURI(url_remote);
    $.ajax({
		async:false,//使用同步的Ajax请求
		type: "POST",  
		url: url_remote,
		data: "",  
		success: function(data){
			var items = data.getElementsByTagName("item");
	   		var result = items[0].childNodes[0].nodeValue;
	        if(result == "fail"){
				window.location = "userlogin.html";
	        }else if(result != "success"){
		       	alert(result);
		       	return false;
	        }else{
	        	document.accountFavorite.target = "_blank";
		       	document.accountFavorite.action = "ordercart.html";
				document.accountFavorite.submit();
	        }
		}
	});
    
}
/**删除一个**/
function deletefavorte(elename,id){
	var url_remote ="newuserjquery.action?usertype=second006&id=" + id;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");   
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result != "success"){
			alert("系统繁忙，请稍后再试");
			return false;
		}else{
			$("#" + elename + id).remove();
		}
	});
}

/**消息状态**/
function msgstatus(id){
	var hiddenid = $("#unread" + id).val();
	if(hiddenid == "n"){
		var url_remote ="newuserjquery.action?usertype=second008&ids=" + id + "&type=readmsg";
		url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "error"){
				window.location.href = templateSrc + "/userlogin.html";
			}else{
				var mag1 = $("#golobmsgcounthead").html();
				var mag2 = $("#golobmsgcountheadtwo").html();
				if(parseInt(mag1) - 1 > 0){
					$("#golobmsgcounthead").html(parseInt(mag1) - 1);
				}else{
					$("#golobmsgcounthead").html(0);
				}
				if(parseInt(mag2) - 1 > 0){
					$("#golobmsgcountheadtwo").html(parseInt(mag2) - 1);
				}else{
					$("#golobmsgcountheadtwo").html(0);
				}
				$("#unread" + id).val("y");
			}
		});
	}
}

/**标记已读**/
function updatestatus(source){
	var id = "";
   	$("input[name='" + source + "']:checked").each(function(){
   		id += $(this).val() + ",";
 	});
 	if(id == ""){
 		alert("请至少选择一项");
 		return false;
 	}
 	if (id.length > 0){
    	//得到选中的checkbox值序列
    	id = id.substring(0,id.length - 1);
	}
 	var url_remote ="newuserjquery.action?usertype=second008&ids=" + id + "&type=readmsg";
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result != "success"){
			alert("系统繁忙，请稍后再试");
			return false;
		}else{
			window.location.href = templateSrc + "/accountmessage.html";
		}
	});
}

/**删除**/
function deletemsg(type,source){
	var id = "";
   	$("input[name='" + source + "']:checked").each(function(){
   		id += $(this).val() + ",";
 	});
 	if(id == ""){
 		alert("请至少选择一项");
 		return false;
 	}
 	if (id.length > 0){
    	//得到选中的checkbox值序列
    	id = id.substring(0,id.length - 1);
	}
 	var url_remote ="newuserjquery.action?usertype=second008&ids=" + id + "&type=delmsg";
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result != "success"){
			alert("系统繁忙，请稍后再试");
			return false;
		}else{
			if("unread" == type){
				window.location.href = templateSrc + "/accountmessage.html?readstatus=n";
			}else{
				window.location.href = templateSrc + "/accountmessage.html?readstatus=y";
			}
		}
	});
}

function unverifydialog(cardnum){
	$("#unverifycardnum").val(cardnum);
	$("#cancelcard").show();
}
/**解绑**/
function realunverify(){
	var cardnumnew = $("#unverifycardnum").val();
	var url_remote ="accountmodify.action?accountType=three006&cardnumber=" + cardnumnew;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == 'fail'){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == 'success'){
			window.location.href = templateSrc + "/myaccountcardcharge.html";
		}else{
			alert("系统繁忙，请稍后再试！");
		}
	});
}

/**切换table**/
function changetable(level,number){
	$(".msgTab li").removeClass().eq(level).addClass("on");
	$(".msgArea").hide().eq(level).show();
	if(level == "1"){
		$("#chargecardnum").val(number);
	}else if(level == "2"){
		$("#webcardnum").val(number);
	}else{
		$("#querycardnum").val(number);
	}
}

/**绑定蜘蛛卡**/
function verifycard(){
	var cardnum = $("#cardnum").val();
	var cardpass = $("#cardpass").val();
	if(cardnum == ""){
		$("#errormsg2").html("");
		$("#errormsg1").html("请输入卡号!");
		$("#cardnum").focus();
		return false;
	}
	if(cardpass == ""){
		$("#errormsg1").html("");
		$("#errormsg2").html("请输入密码!");
		$("#cardpass").focus();
		return false;
	}
	var url_remote ="accountmodify.action";
	var datapost = {
		"accountType":"three005",
		"cardnumber":cardnum,
		"cardpass":cardpass
	};
    url_remote = encodeURI(url_remote);
	$.post(url_remote, datapost, function(data){
		var items = data.getElementsByTagName("item");
   		var result = items[0].childNodes[0].nodeValue;
   		if(result == "fail"){
			window.location = "userlogin.html";
        }
		if(result != "success"){
			if(result.indexOf("卡号") != -1){
				$("#errormsg2").html("");
				$("#errormsg1").html(result);
				$("#cardnum").focus();
			}else{
				$("#errormsg1").html("");
				$("#errormsg2").html(result);
				$("#cardpass").focus();
			}
			return false;
		}else{
			window.location.href = templateSrc + "/myaccountcardcharge.html";
		}
   	});
}

/**充值**/
function cardchongzhi(type){
	var cardnum = $("#chargecardnum").val();
	var repeatcardnum = $("#repeatchargecardnum").val();
	var selamount = $("input[name='camount']:checked").val();
	var paytypeother = $("#paytypeother").val();
	if(type != '1'){
		cardnum = type;
		repeatcardnum = type;
	}
	if(cardnum == ""){
		$("#errorSpan").html("卡号不能为空");
		$("#errorSpanp").show();
		$("#chargecardnum").focus();
    	return false;
	}else if(repeatcardnum == ""){
		$("#errorSpan").html("重复卡号不能为空");
		$("#errorSpanp").show();
		$("#repeatchargecardnum").focus();
    	return false;
	}else if(cardnum != repeatcardnum){
		$("#errorSpan").html("两次卡号输入不一致");
		$("#errorSpanp").show();
		$("#repeatchargecardnum").focus();
		return false;
	}else if(selamount == "" || undefined == selamount){
		$("#errorSpan").html("请选择充值金额");
		$("#errorSpanp").show();
		$("#camount").focus();
    	return false;
	}else if(paytypeother == "" || undefined == paytypeother || null == paytypeother){
		$("#errorSpan").html("请选择支付方式");
		$("#errorSpanp").show();
		$("#paytypeother").focus();
    	return false;
	}else{
		$("#errorSpanp").hide();
	}
	$.ajax({
		async:false,//使用同步的Ajax请求
		type: "POST",  
		url: "accountmodify.action",
		data: "accountType=three003&cardnum=" + cardnum + "&repeatcardnum=" + repeatcardnum + "&selamount=" + selamount+"&paytype="+ paytypeother,  
		success: function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "fail"){
				window.location = "userlogin.html";
			}
			if(result != "success"){
				$("#errorSpan").html(result);
				$("#errorSpanp").show();
				return false;
			}
			var taskid = items[1].childNodes[0].nodeValue;
			var cardid = items[2].childNodes[0].nodeValue;
			var orderid = items[3].childNodes[0].nodeValue;
			$("#amount").val(selamount);
			$("#paytype").val(paytypeother);
			$("#taskid").val(taskid);
			$("#cardnumber").val(cardid);
			$("#charge_orderid").val(orderid);
			$("#id").val("charge");
			document.chargeform.target="_blank";
			document.chargeform.action = "paytype.html";
			document.chargeform.submit();
		}
	});
}

function getcarddetail(cardid){
	var cardnumber = $("#cardnumber"+cardid).val();
	var producttype = $("#producttype"+cardid).val();
	var date = $("#date"+cardid).val();
	var productid = $("#productid"+cardid).val();
	var catalogid = $("#catalogid"+cardid).val();
	var discount = $("#discount"+cardid).val();
	var amount = $("#amount"+cardid).val();
	var fullamount = $("#fullamount"+cardid).val();
	var cardtype = $("#cardtype"+cardid).val();
	var cardname = $("#cardname"+cardid).val();
	var url_remote ="newuserjquery.action?usertype=second011&cardnumber=" + cardnumber + "&producttype=" + producttype + "&date=" + date+"&productid="+productid+"&catalogid="+catalogid+"&discount="+discount+"&amount="+amount+"&fullamount="+fullamount+"&cardtype="+cardtype+"&cardname="+cardname;
	url_remote = encodeURI(url_remote);
	$("#showdialog").html("");
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "login"){
			spiderLogin.util.login();
   		}else if("success" == result){
   			var showmessage = items[1].childNodes[0].nodeValue;
   			showmessage = showmessage.replace("http://www.spider.com.cn/images/img_account/gb.png","http://www.spider.com.cn/images/common/trans.png");
   			$("#showdialog").html(showmessage);
   			$(".bmPop").show();
   			$(".closePp").click(function(){
   		        closePp($(this));
   		    });
   			$(".bmPop .btn a").click(function() {
   				closePp($(this));
   			});
   			$(".btnClose").click(function() {
   				closePp($(this));
   			});
   		}
	});
}

/**蜘蛛网购卡充值**/
function webcardchongzhi(type){
	var cardnum = $("#webcardnum").val();
	var repeatcardnum = $("#repeatwebcardnum").val();
	var selamount = $("input[name='webamount']:checked").val();
	var paytypeother = $("#paytypeweb").val();
	//if(type != '1'){
		//cardnum = type;
		//repeatcardnum = type;
	//}
	if(cardnum == ""){
		$("#weberrorSpan").html("卡号不能为空");
		$("#weberrorSpanp").show();
		$("#webcardnum").focus();
    	return false;
	}else if(repeatcardnum == ""){
		$("#weberrorSpan").html("重复卡号不能为空");
		$("#weberrorSpanp").show();
		$("#repeatwebcardnum").focus();
    	return false;
	}else if(cardnum != repeatcardnum){
		$("#weberrorSpan").html("两次卡号输入不一致");
		$("#weberrorSpanp").show();
		$("#repeatchargecardnum").focus();
		return false;
	}else if(selamount == "" || undefined == selamount){
		$("#weberrorSpan").html("请选择充值金额");
		$("#weberrorSpanp").show();
		$("#webamount").focus();
    	return false;
	}else if(paytypeother == "" || undefined == paytypeother || null == paytypeother){
		$("#weberrorSpan").html("请选择支付方式");
		$("#weberrorSpanp").show();
		$("#paytypeweb").focus();
    	return false;
	}else{
		$("#weberrorSpanp").hide();
	}
	$.ajax({
		async:false,//使用同步的Ajax请求
		type: "POST",  
		url: "accountmodify.action",
		data: "accountType=three003&cardnum=" + cardnum + "&repeatcardnum=" + repeatcardnum + "&selamount=" + selamount+"&paytype="+ paytypeother,  
		success: function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "fail"){
				window.location = "userlogin.html";
			}
			if(result != "success"){
				$("#weberrorSpan").html(result);
				$("#weberrorSpanp").show();
				return false;
			}
			var taskid = items[1].childNodes[0].nodeValue;
			var cardid = items[2].childNodes[0].nodeValue;
			var orderid = items[3].childNodes[0].nodeValue;
			$("#amount").val(selamount);
			$("#paytype").val(paytypeother);
			$("#taskid").val(taskid);
			$("#cardnumber").val(cardid);
			$("#charge_orderid").val(orderid);
			$("#id").val("charge");
			document.chargeform.target="_blank";
			document.chargeform.action = "paytype.html";
			document.chargeform.submit();
		}
	});
}

/**查询充值记录、余额**/
function querycharge(type){
	var querycardnum = $("#querycardnum").val();
	var querypasswd = $("#querypasswd").val();
	if(querycardnum == ""){
		$("#queryerrorSpan").html("卡号不能为空");
		$("#queryout").show();
		$("#querycardnum").focus();
    	return false;
	}else if(querypasswd == ""){
		$("#queryerrorSpan").html("密码不能为空");
		$("#queryout").show();
		$("#querypasswd").focus();
    	return false;
	}else{
		$("#queryout").hide();
	}
	var url_remote ="newuserjquery.action?usertype=second009&cardnumber=" + querycardnum + "&cardpass=" + querypasswd + "&querytype=" + type;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "fail"){
			window.location = "userlogin.html";
   		}else if("0" == result){
   			$("#queryerrorSpan").html("暂无充值记录!");
			$("#queryout").show();
			$("#querycontent").hide();
   			return false;
   		}else if(result != "success"){
			$("#queryerrorSpan").html(result);
			$("#queryout").show();
			return false;
		}else{
			$("#querycontent").show();
			if("chargequery" == type){
				var datestr = items[1].childNodes[0].nodeValue;
  				var pagestr = items[2].childNodes[0].nodeValue;
  				$("#querycontent").html(datestr);
  				$("#querypagecontent").show();
  				$("#querypagecontent").html(pagestr);
			}else if("leftamountquery" == type){
 				var datestr = items[1].childNodes[0].nodeValue;
 				$("#querypagecontent").hide();
 				$("#querycontent").html(datestr);
			}
		}
   	});
}

/**查询结果翻页**/
function turnqueryresult(ele1,ele2,ele3){
	var url_remote ="newuserjquery.action?usertype=second010&extroeleid=" + ele1 + "&extroelenum=" + ele2 + "&pageno=" + ele3;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "fail"){
			window.location = "userlogin.html";
		}else if("0" == result){
			$("#queryerrorSpan").html("暂无充值记录!");
			$("#queryout").show();
			return false;
		}else if(result != "success"){
			$("#queryerrorSpan").html(result);
			$("#queryout").show();
			return false;
		}else{
			var datestr = items[1].childNodes[0].nodeValue;
			var pagestr = items[2].childNodes[0].nodeValue;
			$("#querycontent").html(datestr);
			$("#querypagecontent").html(pagestr);
		}
   	});
}

/** 用蜘蛛充值卡 */
function checkChargeSpider(){
	var cardnumber = $("#cardnumber").val();
	var password = $("#password").val();
	var randomid = $("#randomid").val();
	if("" == cardnumber || null == cardnumber){
		$("#errorSpan2").html("请输入蜘蛛卡号!");
		$("#errordiv2").show();
		$("#cardnumber").focus();
		return false;
	}else{
		$("#errordiv2").hide();
	}
	if("" == password || null == password){
		$("#errorSpan2").html("请输入密码!");
		$("#errordiv2").show();
		$("#password").focus();
		return false;
	}else{
		$("#errordiv2").hide();
	}
	if("" == randomid || null == randomid){
		$("#errorSpan2").html("请输入验证码!");
		$("#errordiv2").show();
		$("#randomid").focus();
		return false;
	}else{
		$("#errordiv2").hide();
	}
	var url_remote ="accountmodify.action?accountType=first004&cardnumber=" + cardnumber+"&password="+password+"&randomid="+randomid;
    url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
       	var items = data.getElementsByTagName("item");
   		var result = items[0].childNodes[0].nodeValue;
   		if("fail" == result){
			window.location = "userlogin.html";
   		}else if(result.indexOf("充值失败") != -1){
   			$("#chargefalse").show();
   		}else if("success" != result){
			$("#errorSpan2").html(result);
			$("#errordiv2").show();
			randomidbetter(document.accountFrom.verifycode_id);
			return false;
		}else{
			$("#chargesuccess").show();
		}
   	});
}

function testamount(s) {
	var re =/^(([1-9]\d*)|0)(\.\d{1,2})?$/;
	return re.test(s);
}

function selform(num){
	$(".payItem").hide().eq(num).show();
	if(num == "2"){
		$("#cardnumber").val("");
		$("#password").val("");
	}
}

/** 第三方接口充值 */
function checkChargeOther(){
	var amount = $("#amountother").val();
	var paytype = $("input[name=selpaytype]:checked").val();
	if("" == amount || null == amount){
		$("#errorSpan").html("请输入充值金额!");
		$("#errordiv").show();
		$("#amountother").focus();
		return false;
	}else{
	     re = /^\d+\.?\d*$/
		 if(!re.test(amount)){
		    $("#errorSpan").html("充值金额只能为数字!");
			$("#errordiv").show();
			$("#amountother").focus();
			return false;
		 }else{
		 	var rate = amount%50;
	 		if(amount<100){
		 		$("#Popup_pro_tc").show();
				$(".mask").show();
				$("body").css('overflow','hidden');
				$("#amountother").focus();
				return false;
			 }else{
			 	$("#errordiv").hide();
			 }
		 }
	}
	if("" == paytype || null == paytype){
		$("#errorSpan").html("请选择要支付的银行!");
		$("#errordiv").show();
		$("#selpaytype").focus();
		return false;
	}else{
		$("#errordiv").hide();
	}
	$("#amount").val(amount);
	$("#paytype").val(paytype);
	document.accountFrom.target="_blank";
	document.accountFrom.action = "paytype.html";
	document.accountFrom.submit();
}

//通联
function checkChargeAip(){
	var amountaip = $("#amountaip").val();
	if("" == amountaip || null == amountaip){
		$("#errorSpan1").html("请输入充值金额!");
		$("#errordiv1").show();
		$("#amountaip").focus();
		return false;
	}else{
	     re = /^\d+\.?\d*$/
		 if(!re.test(amountaip)){
		    $("#errorSpan1").html("充值金额只能为数字!");
			$("#errordiv1").show();
			$("#amountaip").focus();
			return false;
		 }else{
		 	if(amountaip<0.01){
			    $("#errorSpan1").html("充值金额至少一分钱");
				$("#errordiv1").show();
				$("#amountaip").focus();
				return false;
			}else{
				$("#errordiv1").hide();
			}
		}
	}
	$("#amount").val(amountaip);
	$("#paytype").val("aip");
	document.accountFrom.target="_blank";
	document.accountFrom.action = "paytype.html";
	document.accountFrom.submit();
}
/**外部div切换**/
function showoutdiv(status,type){
	$(".msgCty li").removeClass("on");
	$("#" + status + type).addClass("on");
	/**外部div加载一次后不再加载，当筛选小分类后再次加载**/
	var flag = "y";
	if(type == '' || type == null){
		$(".msgCty li").removeClass("on");
		var value = $("#" + status + "flag").val();
		if(value == 1){
			flag = "n";
		}
	}
	if(flag == 'y'){
		$("#" + status + "usepage").html("");
		$("#" + status + "usecontent").html("<li>加载中,请稍后...</li>");
		var url_remote ="newuserjquery.action?usertype=three001&status=" + status + "&producttype=" + type + "&pageno=1";
		url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function (data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "error"){
				window.location.href = templateSrc + "/userlogin.html";
			}else if(result == "success"){
				$("#" + status + "usecontent").html(items[1].childNodes[0].nodeValue);
				$("#" + status + "usecontent").show();
				$(".msgZone").show();
				$("#" + status + "usepage").html(items[2].childNodes[0].nodeValue);
				$("#" + status + "usepage").show();
				if(type == '' || type == null){
					$("#" + status + "flag").val("1");
				}else{
					$("#" + status + "flag").val("0");
				}
			}else if(result == "0"){
				$("#" + status + "usecontent").html("<li>没有找到相应的记录！</li>");
				$("#" + status + "usecontent").show();
				$("#" + status + "usepage").html("");
				$("#" + status + "usepage").show();
				if(type == '' || type == null){
					$("#" + status + "flag").val("1");
				}else{
					$("#" + status + "flag").val("0");
				}
			}else if(result == "false"){
				alert("系统繁忙，请稍后再试！");
			}
		});
	}
}

/**抵用券页面翻页**/
function turncouponpage(status,type,pageno){
	var url_remote ="newuserjquery.action?usertype=three001&status=" + status + "&producttype=" + type + "&pageno=" + pageno;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("#" + status + "usecontent").html(items[1].childNodes[0].nodeValue);
			$("#" + status + "usepage").html(items[2].childNodes[0].nodeValue);
		}else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}
	});
}

/**绑抵用券**/
function verifycoupon(){
	var cardnumber = $("#cardnumber").val();
	var randomid = $("#randomid").val();
	$("#errormsg1").html("");
	$("#errormsg2").html("");
	if("" == cardnumber || null == cardnumber){
		$("#errormsg1").html("请输入您要添加的劵号");
		$("#cardnumber").focus();
		return false;
	}else{
		$("#errormsg1").html("");
	}
	if("" == randomid || null == randomid){
		$("#errormsg2").html("请输入验证码");
		$("#randomid").focus();
		return false;
	}else{
		$("#errormsg2").html();
	}
	var url_remote ="newuserjquery.action?usertype=three002&cardnumber=" + cardnumber + "&radom=" + randomid;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if("error" == result){
			window.location = "userlogin.html";
   		}else if(result != "success"){
   			if(result.indexOf("券号") != -1){
   				$("#errormsg1").html(result);
				$("#cardnumber").focus();
   			}else{
	   			$("#errormsg2").html(result);
				$("#randomid").focus();
   			}
			randomidbetter(document.accountFrom.verifycode_id);
			return false;
		}else{
			window.location.href = templateSrc + "/myaccountyhj.html";
			//document.accountFrom.reset();
			//$("#coupondig").hide();
			//$('.mask').hide();
			//alert("绑定成功");
		}
	});
}

/**积分页面翻页**/
function turnjifenpage(catalog,jftype,timetype,pageno){
	var url_remote ="newuserjquery.action?usertype=three003&temptype=" + catalog + "&jftype=" + jftype + "&timetype=" + timetype + "&pageno=" + pageno;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$(".odd").remove();
			$(".even").remove();
			$("#" + catalog + "content").after(items[1].childNodes[0].nodeValue);
			$("#" + catalog + "page").html(items[2].childNodes[0].nodeValue);
		}else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}
	});
}

/**下拉框变动**/
function changesel(divtype){
	var jftype = $("#" + divtype + "typejifen option:selected").val();
	var timetype = $("#" + divtype + "jifen option:selected").val();
	var url_remote ="newuserjquery.action?usertype=three003&temptype=" + divtype + "&jftype=" + jftype + "&timetype=" + timetype + "&pageno=1";
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$(".odd").remove();
			$(".even").remove();
			$("#" + divtype + "content").after(items[1].childNodes[0].nodeValue);
			$("#" + divtype + "page").html(items[2].childNodes[0].nodeValue);
		}else if(result == "0"){
			$(".odd").remove();
			$(".even").remove();
			$("#" + divtype + "content").after("<tr class=\"odd\"><td class=\"nocont\" colspan=\"4\">没有找到相应的记录！</td></tr>");
			$("#" + divtype + "page").html("");
		}
		else if(result == "false"){
			alert("系统繁忙，请稍后再试！");
		}
	});
}

/**我的积分div切换**/
function changediv(type){
	var typevalue = $("#" + type + "divvalue").val();
	if(typevalue != 1){
		$("#" + status + "usecontent" + type).html("<li>加载中,请稍后...</li>");
		var url_remote ="newuserjquery.action?usertype=three003&temptype=" + type + "&pageno=1";
		url_remote = encodeURI(url_remote);
		$.post(url_remote, null, function (data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "error"){
				window.location.href = templateSrc + "/userlogin.html";
			}else if(result == "success"){
				$("#" + type + "content").after(items[1].childNodes[0].nodeValue);
				$("#" + type + "page").html(items[2].childNodes[0].nodeValue);
				$("#" + type + "divvalue").val("1");
			}else if(result == "0"){
				$("#" + type + "content").after("<tr class=\"odd\"><td class=\"nocont\" colspan=\"4\">没有找到相应的记录！</td></tr>");
				$("#" + type + "page").html("");
				$("#" + type + "divvalue").val("1");
			}
			else if(result == "false"){
				alert("系统繁忙，请稍后再试！");
			}
		});
	}
}

/**点击去聊天**/
function chatsubmit(receCustomerid,source,p,applytype,appdateno,appdateidtwo,waitflag,chatflag,row,pointsstatus){
	/**判断用户是否登录**/
   	var url_remote = "newuserjquery.action?usertype=first005";
   	$.ajax({
         async:false,//使用同步的Ajax请求
         type: "POST",  
         url: url_remote,  
         data: "",  
         success: function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "fail"){
				window.location = templateSrc + "/userlogin.html";
			}else{
				if(result != "success"){
					alert(result);
					return;
				}else{
					if(null == receCustomerid || '' == receCustomerid){
						alert("请选择聊天用户！");
						return;
					}
					/**去掉头像的小点**/
					pointschange(source,p,row,pointsstatus,appdateidtwo);
					/**这里判断用户能否聊天**/
					var canchat = true;
					if("publish" == source && (applytype == '1' || applytype == '2')){
						var url_remote1 ="newuserjquery.action?usertype=three006&temptype=verifychat&datingid=" + appdateno + "&applyid=" + receCustomerid;
						url_remote1 = encodeURI(url_remote1);
						$.ajax({
							async:false,//使用同步的Ajax请求
							type: "POST",
							url: url_remote1,
							data: "",
							success: function(data){
								var items1 = data.getElementsByTagName("item");
								var result1 = items1[0].childNodes[0].nodeValue;
								if(result1 == "true"){
									canchat = true;
								}else{
									canchat = false;
								}
							}
						});
					}
					if(canchat){
						if("publish" == source){
							$("#receCustomerid").val(receCustomerid);
							$("#receCustomername").val($("#applyalias" + receCustomerid).val());
							
							$("#filmname").val($("#filmname" + p).text());
							$("#filmaddress").val($("#filmaddress" + p).text());
							$("#filmdate").val($("#filmdate" + p).text());
						}else{
							$("#receCustomerid").val(receCustomerid);
							$("#receCustomername").val($("#publishalise" + receCustomerid).val());
							
							$("#filmname").val($("#afilmname" + p).text());
							$("#filmaddress").val($("#afilmaddress" + p).text());
							$("#filmdate").val($("#afilmdate" + p).text());
						}
						$("#chatflag").val(chatflag);
						$("#appdateno").val(appdateno);
						$("#appdateidtwo").val(appdateidtwo);
						$("#applytypestatus").val(applytype);
						$("#datingtype").val(source);
						$("#waitflag").val(waitflag);
						document.chatform.target = "_blank";
						document.chatform.submit();
					}else{
						$("#chtpp").show();
					}
				}
			}
         }
     });
}

/**更新头像小点**/
function pointschange(source,p,row,pointsstatus,appdateidtwo){
	if("y" != pointsstatus){
		if("publish" == source){
			var flag = $("#point" + source + p + row + row).val();
			if(flag == 0){
				$("#point" + source + p + row).hide();
				$("#point" + source + p + row + row).val("1");
				var url_remote ="newuserjquery.action?usertype=three006&temptype=pointstatus&datingtype=" + source + "&applyid=" + appdateidtwo;
				url_remote = encodeURI(url_remote);
				$.post(url_remote, null, function (data){
					
				});
			}
		}else{
			var flag = $("#point" + source + p + p).val();
			if(flag == 0){
				$("#point" + source + p).hide();
				$("#point" + source + p + p).val("1");
				var url_remote ="newuserjquery.action?usertype=three006&temptype=pointstatus&datingtype=" + source + "&applyid=" + appdateidtwo;
				url_remote = encodeURI(url_remote);
				$.post(url_remote, null, function (data){
					
				});
			}
		}
	}
}

function randomidbetter(obj) {
	obj.src = templateSrc + "/verifycode.jsp?" + new Date;
}

/**发送观影信息**/
function sendguanying(ele,id,datingid,applyid){
	var url_remote ="newuserjquery.action?usertype=three006&temptype=sendguanying&datingid=" + datingid + "&applyid=" + applyid;
	url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function (data){
		var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location.href = templateSrc + "/userlogin.html";
		}else if(result == "success"){
			$("#" + ele + id).show();
			$("." + ele).html("<a style=\"cursor: default;color: gray;text-decoration:none\" href=\"javascript:void(0)\" class=\"send\">发送观影信息</a>");
			$("#outside" + ele.replace('guanying','')).removeClass().addClass("yueItem yuend");
			$(".liaotian" + ele.replace('guanying','')).html("<a href=\"javascript:void(0)\" class=\"chat\">聊一聊</a>");
		}else{
			alert("系统繁忙，请稍后再试!");
		}
	});
}

function KeyChk_Num() {
	var cKey = window.event.keyCode;
	if ((cKey < 48)	|| (cKey > 57) || (cKey == 45)) {
		if(cKey != 58){
			event.keyCode=0;
			event.returnValue=0;
		};
	};
}

/**积分兑换申请**/
function pointapply(){
	var points = $("#points").val();
	var randomid = $("#randomidpoints").val();
	var customerpoints = $("#customerpoints").val();
	if(points == ""){
		$("#errorSpanexchange").html("申请积分不能为空!");
		$("#errordivexchange").show();
		$("#points").focus();
	 	return false;
	}else{
	    var r = /^\+?[1-9][0-9]*$/;
	    if(!r.test(points)){
	        $("#errorSpanexchange").html("积分只能为整数!");
			$("#errordivexchange").show();
			$("#points").focus();
			return false;
	    }else{
		    $("#errordivexchange").hide();
		}
	}
	if(parseInt(points) < 1200){
		$("#errorSpanexchange").html("单次兑换的积分不能少于1200");
		$("#errordivexchange").show();
		$("#points").focus();
		return false;
	}
	if(customerpoints.indexOf(".") != -1){
		customerpoints = customerpoints.split(".")[0];
	}
	if(eval(points) > eval(customerpoints)){
		$("#exchangecontent").html("对不起，您最多只能使用" + customerpoints + "积分兑换");
		$("#exchangefalse").show();
		return false;
	}
	if(randomid == ""){
		$("#errorSpanexchange").html("验证码不能为空!");
		$("#errordivexchange").show();
		$("#randomidpoints").focus();
	 	return false;
	}else{
		$("#errordivexchange").hide();
	}
	var url_remote ="newuserjquery.action?usertype=three0011&points=" + points+"&randomid="+randomid;
    url_remote = encodeURI(url_remote);
	$.post(url_remote, null, function(data){
    	var items = data.getElementsByTagName("item");
		var result = items[0].childNodes[0].nodeValue;
		if(result == "error"){
			window.location = "userlogin.html";
		}
		randomidbetter(document.moblieform.verifycode_id);
		if(result == "false"){
			$("#exchangecontent").html("系统繁忙!请稍后再试!");
		}else if(result != "success"){
			$("#exchangecontent").html(result);
		}else{
			$("#points").val("");
			$("#randomidpoints").val("");
			$("#exchangecontent").html("兑换成功，系统正在审核中。审核通过后兑换所得蛛元将立即充入到您的蛛元账户中");
		}
		$("#exchangefalse").show();
	})
}

function applyReimbursement(orderInfoSign){
	var url_remote = "newuserjquery.action?usertype=four003&orderInfoSign=" + orderInfoSign;
	$.ajax({
		async:false,//使用同步的Ajax请求
		type: "POST",
		url: url_remote,
		data: "",
		success: function(data){
			var items = data.getElementsByTagName("item");
			var result = items[0].childNodes[0].nodeValue;
			if(result == "error"){
				window.location.href = templateSrc + "/userlogin.html";
			}else if(result == "false"){
				alert("你已经提交报销了，不能重复提交");
			}else if(result == "payerror"){
				alert("订单无现金支付额度，不能报销");
			}else if(result == "timeerror"){
				alert("活动已结束");
			}else if(result == "success"){
				var redirecturl = items[1].childNodes[0].nodeValue;
				var openLink = $("#hidealink");
				openLink.attr('href', redirecturl);
				openLink[0].click();
			}
		}
	});
}

function agreeChargeProtocol(checkid,buttonid,clickfunc){
	if($('#' + checkid).is(':checked')){
		$("#" + buttonid).html("<a href=\"javascript:void(0)\" onclick=\"" + clickfunc + "()\">立即充值</a>");
	}else{
		$("#" + buttonid).html("<a class=\"gray\">立即充值</a>");
	}
}

/**获取url中的参数值**/
function getUrlParam(name){  
    //构造一个含有目标参数的正则表达式对象  
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");  
    //匹配目标参数  
    var r = window.location.search.substr(1).match(reg);  
    //返回参数值  
    if (r!=null) return unescape(r[2]);  
    return null;  
}